package com.spring.Connection;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.GenericXmlApplicationContext;

import java.sql.SQLException;


public class UserDaoTest{
	public static void main(String[] args)throws ClassNotFoundException, SQLException{
//		ApplicationContext context = new AnnotationConfigApplicationContext(DaoFactory.class);
//		UserDao companyA = context.getBean("userDao", UserDao.class);
		
		ApplicationContext context = new GenericXmlApplicationContext("com/spring/Connection/applicationContext.xml");
		UserDao companyA = context.getBean("userDao", UserDao.class);
		
		
		User user = new User("timec","123123","김동준");
//		
		String company = "CompanyA";
//		
		/*
		 * table 생성
		 */
		companyA.createTable();
		
		
		/*
		 * table 값 입력
		 */
		companyA.insertUser(user);
		
		
		/*
		 * table 값 조회
		 */
		companyA.selectUser("timec");
		
		
		/*
		 * table 값 갱신
		 */
		user.setName("드림인프라");
		user.setPassword("567567");
		companyA.updateUser(user);
		companyA.selectUser("timec");
		
		
		/*
		 * table 값 삭제
		 */
		companyA.deleteUser("timec");
	}
}
